/**
 * Copyright (c) 2013 onionframework.org
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 */
package org.onionframework.core.exception;

/**
 * 业务异常
 * 
 * @author allan
 *s
 */
public class BusinessException extends RuntimeException {

	private static final long serialVersionUID = 8469865609848058462L;
	private Object source;
	
	public BusinessException(String message){
		super(message);
	}
	
	public BusinessException(String message,Throwable cause){
		super(message,cause);
	}
	
	public BusinessException(Throwable cause){
		super(cause);
	}
	
	
	public BusinessException(Throwable cause, Object source){
		super(cause);
		this.source = source;
	}
	
	/**
	 * @return the source
	 */
	public Object getSource() {
		return source;
	}
	
	@Override
	public String getMessage(){
		String message = super.getMessage();
		if(message != null)
			return message;
		else if(this.getCause() != null)
			return this.getCause().getMessage();
		else
			return null;
	}
}
